/**
 * Project Name:Micro-Services-RPC-API
 * File Name   :AbstractResult.java
 * Package Name:com.micro.services.rpc
 * Date:2015-9-9下午4:04:38
 * Copyright (c) 2015, http://my.oschina.net/httpssl All Rights Reserved.
 *
*/

package com.micro.services.rpc.support;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


/**
 * ClassName:AbstractResult <br/>
 * Function :TODO ADD FUNCTION. <br/>
 * Reason	:TODO ADD REASON. <br/>
 * Date     :2015-9-9 下午4:04:38 <br/>
 * @author  :http://my.oschina.net/httpssl
 * @email   :491835898@qq.com
 * @since   :JDK 1.7
 * @see 	 
 */
public abstract class AbstractResult implements StatusResult
{
	protected static final long	serialVersionUID	= 1L;
	/*
	 * RPC result value 
	 */
	protected Object result_value ;
	
	protected Throwable throwable;
	
	protected ConcurrentHashMap<String,Object> attachments = new ConcurrentHashMap<String,Object>();
	
	public AbstractResult(){
	}
	public AbstractResult(Object result)
	{
		super();
		this.result_value = result;
	}
	
	@Override
	public Map<String, Object> getAttachments() {
		// TODO Auto-generated method stub
		return attachments;
	}
	
	@Override
	public Object getAttachment(String key) {
		// TODO Auto-generated method stub
		return attachments.get(key);
	}
	
	@Override
	public Throwable getException() {
		return throwable;
	}
	
	@Override
	public int getResultStatusCode() {
		// TODO Auto-generated method stub
		return StatusResult.SC_OK;
	}
	
	@Override
	public Object getValue() {
		return result_value;
	}
}
